package com.example.wanted.service;

import com.example.wanted.model.User;
import com.example.wanted.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    final UserRepository userRepository;

    @Autowired
    public UserService(@Qualifier("user") UserRepository userRepository) {
        this.userRepository = userRepository;
    }

    public void save(User user){
         userRepository.save(user);
    }



    public User findByName(String name) {
        return userRepository.findByName(name);
    }

    public boolean canfindByOpenid(String openid){
        if(userRepository.findByOpenid(openid)!=null){
            return true;
        }else{
            return false;
        }

    }

    public User findByOpenid(String openid) {
        return userRepository.findByOpenid(openid);
    }

    //檢查用戶名是否被使用

    //檢查用戶密碼是否正确
}
